﻿<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/commons/taglibs.jsp" %>
<%@ page import="java.io.*" %>
<%@ page import="java.net.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="${ctx}/scripts/jquery-1.4.2.min.js"></script> 
<script type="text/javascript" src="${ctx}/scripts/jquery.pagination.js"></script> 
<title>北京车辆段</title>
<link href="${ctx}/css/index.css" rel="stylesheet" type="text/css" /> 
<link href="${ctx}/scripts/pagination.css" rel="stylesheet" type="text/css" /> 

<script type="text/javascript">

	var iTimeoutIdB=""; 
	var indexB=0; //默认第一个显示的图片的索引
	var showTimeB=4000; //显示时间（单位：毫秒）
	var img_VanishTimeB=500; //逐渐显示的时间（单位：毫秒） 
	
	var iTimeoutId=""; 
	var index=0; //默认第一个显示的图片的索引
	var showTime=4000; //显示时间（单位：毫秒）
	var img_VanishTime=500; //逐渐显示的时间（单位：毫秒）
			  
	var t = n = count = 0;
	
	function printNews(){	       
		 var url ="${ctx}/news/printnews.jsp?fileTypes=NEWS&newsid="+document.getElementById("newsid").value;
		 window.open(url, "win");
	}
			       
	 function downloadNews(){
	  	 location.href="${ctx}/files/Files/download.do?fileTypes=NEWS&fileName="+document.getElementById("newsid").value;
	  }
	  
     function search(){
		 document.form1.method = "post";
		 document.form1.action = "${ctx}/web/Web/listNews.do";
		 document.form1.submit();

	 }
	 $(document).ready(function() { 
	      initData(); //初始菜单 标题 天气预报、安全天数等信息 	
	       
	 }); 	 
	function initData(){
     $.get('${ctx}/news/Menu/topList.do?t='+Math.random(), function(josn) {
         	 if(josn!=""){
		     josn = josn.replace(new RegExp("null","gm"),'""');
		     var mydata = eval("("+josn+")");
			     if(mydata.weather!=''){
			     
			       var ojb=mydata.weather; 
			       var temp=ojb.names.replace(new RegExp("#","gm"),'<br>'); 
			       
			       document.getElementById("weather").innerHTML='<img src="${ctx}'+ojb.urls+'" height="50px"/>'+'<div>'+temp+'</div>';
			        
			   }
			    
			    if(mydata.menus!=''){
			      var ojb=mydata.menus;
			      var content='';
			      for(var i=0;i<ojb.length;i++){
			        if(ojb[i].urls==''){
			           ojb[i].urls='#';
			        } 
			        content+='<li>';
			        content+='<a href="'+ojb[i].urls+'">'+ojb[i].names+'</a>';
			        content+='<ul>';
			        content+='<li><a href="'+ojb[i].urls+'">'+ojb[i].names+'</a></li>';
                    if(ojb[i].childrenMenu!=''){
                        var children=ojb[i].childrenMenu;
 						for(var j=0;j<children.length;j++){ 
							content+='<li><a href="'+children[j].urls+'">'+children[j].names+'</a></li>';
						 }
						
			         }
			         content+='</ul>';
			         content+='</li>';
			         
			      }
			     // alert(content);
			      document.getElementById("nav").innerHTML=content;
			      menuFix();
			   }
			    if(mydata.topTitle!=''){
			      var ojb=mydata.topTitle;
			      var content='<dl>';
			      for(var i=0;i<ojb.length;i++){
			        if(i>0&&i%2==0){
			            content+='</dl><dl>';
			        }
					if('${sessionScope.username}'!= '') {    		
 				        content+='<dd><a href="'+ojb[i].urls+'">'+ojb[i].names+'</a> </dd>';					
				    }else{		 
				        if(ojb[i].names == '支出动态表' || ojb[i].names == '通讯录' || ojb[i].names == '值班表'){
				             content+='<dd><a href="javascript:alert(\'您没有登录或者您的账号没有访问权限！\');">'+ojb[i].names+'</a></dd>';
				       			
				        }else{       
					 		 content+='<dd><a href="'+ojb[i].urls+'">'+ojb[i].names+'</a> </dd>';	
					    }					
				    }
				  }
			      content+=' <div class="clear"></div>'; 
			      document.getElementById("logo_middle").innerHTML=content;
			      
			     
			   } 
			   
			}
			  
        }) ;  
     } 
	function menuFix() { 
	 var sfEls = document.getElementById("nav").getElementsByTagName("li");
	 	for (var i=0; i<sfEls.length; i++) {
		  sfEls[i].onmouseover=function() {
		  var ul = this.getElementsByTagName("ul")[0];
			  if(ul){
			      ul.style.display = "block";
				  this.className+=(this.className.length>0? " ": "") + "sfhover";
			  }
		  }
		  sfEls[i].onmouseout=function() {
		  		var ul = this.getElementsByTagName("ul")[0];
			  if(ul){
			      ul.style.display = "none";
			  	   this.className+=(this.className.length>0? " ": "") + "sfhover";
			  }
		  }
		 }
     }		
</script>
</head>
<body >
<div class="box" >
 <div class="top">
    	<div class="Tright"><a href="#">收藏本页</a><span>|</span><a href="#">设为首页</a></div>
        您好，欢迎光临北京车辆段！
    </div> 
	 <div class="top_img">   	
		<div class="column">
         <div class="photo" id="photo">
          <ul class="clear" id="photo-sub" style="width:2944px;height:200px">
           <li><a href="#" title="图片说明一" target="_blank"><img src="${ctx}/images/web/qj3.jpg" /></a></li>
            <li><a href="#" title="图片说明一" target="_blank"><img src="${ctx}/images/web/qj1.jpg" /></a></li>
           <li><a href="#" title="图片说明一" target="_blank"><img src="${ctx}/images/web/qj.jpg" /></a></li>
           <li><a href="#" title="图片说明一" target="_blank"><img src="${ctx}/images/web/qj1.jpg" /></a></li>
          </ul>
         </div>
        </div>	
    </div>  
    <script type="text/javascript" src="${ctx}/scripts/lunbo.js"></script>
    <div class="logo_box">
    	<div class="logo"><a href="#"><img src="${ctx}/images/web/logo.jpg" /></a></div>
        <div id="logo_middle" class="logo_middle">
         
            
            <div class="clear"></div>
        </div>
        <div class="logo_tq">
        	 
            <div id="weather">
             
            </div>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="nav_box">
    	<ul id="nav">
          
		</ul>
    </div>
    <div class="login_box">
         
    	<div class="login">
        <form id="forms" action="${ctx}/web/Web/webLogin.do" method="post">
         <input type="hidden" id="newsid" name="newsid" value="<%=request.getParameter("newsid")%>" /> 
           
          <c:if test="${sessionScope.username==null||sessionScope.username==''}" >
            用户名：<input name="userName" type="text" class="shurubox" />
            密码：<input name="userPwd" type="password" class="shurubox" />
          <input type="button" onclick="login()" value="立即登录" class="liji" />
          </c:if>
            <c:if test="${sessionScope.username!=null&&sessionScope.username!=''}" >
                您好!&nbsp;${sessionScope.username}  
                 &nbsp;<a  href="${ctx}/web/Web/webLogout.do" style="color:#6c6c6c;cursor:pointer;"> [退出] </a>
				 <a href="javascript:openpwd();" style="color:#6c6c6c;cursor: pointer;"  >[修改密码] </a>
           </c:if>
          <c:if test="${requestScope.result!=null&&requestScope.result!=''}" >
			 <script type="text/javascript" >
			     alert('${requestScope.result}'); 
			 </script>
		 </c:if> 
          </form>
      
        </div>
        <div class="login_search">
       <form name = "form1">
        	  <input type="text" name="newskeyword" value="请输入搜索关键字" class="search_box"  onfocus="if(value =='请输入搜索关键字'){value =''}" onblur="if (value ==''){value='请输入搜索关键字'}"/> <input type="button" class="search_but" value="" onclick = "javascript:search();"/>
       </form>
        </div>
        <div class="clear"></div>
    </div>
    <br/>
    
    <div class="content">
    	 
<%      
		String numb="";
		String dt="";
		if(request.getParameter("numb")!=null&&!"".equals(request.getParameter("numb"))){
		   numb=request.getParameter("numb");
		}
		if(request.getParameter("dt")!=null&&!"".equals(request.getParameter("dt"))){
		   dt=request.getParameter("dt");
		   if(dt.indexOf("-", 5)>0){
		      String[]  temps=dt.split("-");
		      if(temps.length>2){  
		          if(temps[1].startsWith("0")){
		              dt=temps[0]+temps[1].substring(1);
		          }else{
		             dt=temps[0]+temps[1];
		          }
		      }
		      
		      
		   }
		}
        String newsUrl="http://10.128.4.75/ssxw/xwzx/build/file/"+dt+"/"+numb+".asp";
        //
		URL url=new URL(newsUrl); 
		URLConnection conn = url.openConnection();
	        
		BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
		String line = null;
		
		StringBuffer strBuffer=new StringBuffer();
        while ((line = reader.readLine()) != null) {
        	strBuffer.append(line);
        	
		} 
        reader.close();
     try{   
      if(strBuffer!=null){
        String content=strBuffer.toString();
       int begin=content.indexOf("<TABLE cellSpacing=0 cellPadding=0 width=540 align=center border=0>");
       int end=content.indexOf("<TABLE cellSpacing=0 cellPadding=4 width=597 align=left bgColor=#aaaaff border=0>");
       if(begin<=0)
         begin=content.indexOf("<TABLE border=0 cellSpacing=0 cellPadding=0 width=540 align=center>");
        if(end<=0)
         end=content.indexOf("<TABLE border=0 cellSpacing=0 cellPadding=4 width=597 bgColor=#aaaaff align=left>");   
         
      if(begin>0&&end>0){
      
        content=content.substring(begin,end);
      } 
      
      content=content.replaceAll("showimg.asp", "http://10.128.4.75/ssxw/xwzx/showimg.asp");
      content=content.replaceAll("../../../", "");
       content=content.replaceAll("/zdfile/", "http://10.128.4.75/zdfile/");
      content=content.replaceAll("text1.asp", "newsdetail.jsp"); 
       content=content.replaceAll("http://10.128.4.34", "");
      content=content.replaceAll("width=540", "width=980");
      content=content.replaceAll("width=565", "width=980");
       content=content.replaceAll("width=563", "width=980");
      content=content.replaceAll("width=153", "width=980");
       
       out.print(content);
      }
      }catch(Exception e){
       System.out.print(e);
      }
  %>     
        <div class="clear"></div>
    </div> 
    </div>  
    <div  align="center">
    <div class="footer"><ul>Copyright ©2011-2012 北京车辆段 版权所有</ul>
								信息技术科 联系电话：010-51868237
	</div>
	</div>
</div>  
</body>
</html>
